package com.alan.springbootmybatisxml.service.impl;


import com.alan.springbootmybatisxml.entity.User;
import com.alan.springbootmybatisxml.mapper.UserMapper;
import com.alan.springbootmybatisxml.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author Alan
 * @Description
 * @date 2020年03月28日 22:37
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUsers() {
        List<User> users=userMapper.getAll();
        return users;
    }

    @Override
    public User getUser(Long id) {
        User user=userMapper.getOne(id);
        return user;
    }

    @Override
    public void save(User user) {
        userMapper.insert(user);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    @Override
    public void delete(Long id) {
        userMapper.delete(id);
    }
}
